import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/Home'
import Console from '@/pages/MyConsole'
import Harvest from '@/pages/Harvest'
import Correct from '@/pages/Correct'
import Identify from '@/pages/Identify'
import Search from '@/pages/Search'
import SignUp from '@/pages/SignUp'
import LoginIn from '@/pages/LoginIn'
import Setting from '@/pages/Setting'
import HarvestAlbum from '@/pages/HarvestAlbum'
import IdentifyAlbum from '@/pages/IdentifyAlbum'
import Test from '@/pages/test'

const originalPush = Router.prototype.push;

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/test',
      name: 'test',
      component: Test
    },
    {
      path: '/',
      name: 'home',
      component: Home
    },

    {
      path: '/console',
      name: 'console',
      component: Console
    },
    {
      path: '/harvest',
      name: 'harvest',
      component: Harvest
    },
    {
      path: '/correct',
      name: 'correct',
      component: Correct
    },
    {
      path: '/identify',
      name: 'identify',
      component: Identify
    },
    {
      path: '/search',
      name: 'search',
      component: Search
    },
    {
      path: '/sign-up',
      name: 'sign-up',
      component: SignUp
    },
    {
      path: '/login-in',
      name: 'login-in',
      component: LoginIn
    },
    {
      path: '/setting',
      name: 'setting',
      component: Setting
    },
    {
      path: '/harvest-album/:id',
      name: 'harvest-album',
      component: HarvestAlbum
    },
    {
      path: '/identify-album/:id',
      name: 'identify-album',
      component: IdentifyAlbum
    }

  ],
  scrollBehavior(to, from, savedPosition) {
    return {x: 0, y: 0}
  }
})
